
#include <tchar.h>
#include "Version.h"

static TCHAR* g_szSysVerDesc[] = {
    _T("Windows_Unknow"),
    _T("Windows_Nt_4"),
    _T("Windows_95"),
    _T("Windows_98"),
    _T("Windows_Me"),
    _T("Windows_2000"),
    _T("Windows_xp"),
    _T("Windows_2003"),
    _T("Windows_Vista"),
    _T("Windows_7")
};

CVersion::CVersion(void)
{
}


CVersion::~CVersion(void)
{
}

LPCTSTR
CVersion::GetSystemVerionDesc(
    VOID
)
{
    return g_szSysVerDesc[GetSystemVersion()];
}

ENUMWINDOWSVERSION
CVersion::GetSystemVersion(
    VOID
)
{
    SYSTEM_INFO SysInfo;
    OSVERSIONINFOEX os;
    ENUMWINDOWSVERSION nType = Windows_Unknow;

    GetSystemInfo(&SysInfo);
    os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
    if(GetVersionEx((OSVERSIONINFO *)&os)){ 
        switch(os.dwMajorVersion){
            case 4: 
                switch(os.dwMinorVersion){
                case 0: 
                    if(VER_PLATFORM_WIN32_NT == os.dwPlatformId) 
                        nType = Windows_Nt_4;
                    else if(VER_PLATFORM_WIN32_WINDOWS == os.dwPlatformId) 
                        nType = Windows_95; 
                    break; 
                case 10: 
                    nType = Windows_98; 
                    break; 
                case 90: 
                    nType = Windows_Me; 
                    break; 
                } 
                break; 
            case 5: 
                switch(os.dwMinorVersion){
            case 0: 
                nType = Windows_2000;
                break; 
            case 1: 
                nType = Windows_xp;
                break; 
            case 2: 
                nType = Windows_2003;
                break; 
                } 
                break; 
            case 6: 
                switch(os.dwMinorVersion){ 
                case 0: 
                    nType = Windows_Vista; 
                    break; 
                case 1: 
                    nType = Windows_7;
                    break; 
                } 
                break; 
            default: 
                nType = Windows_Unknow; 
        }
        return nType; 
    } 
    else 
        return Windows_Unknow;
}